<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Logout extends CI_Controller {

	public function index ()
	{

		// load helpers and models
		$this->load->helper('url');
		$this->load->model('auth/auth');

		// search cookies for auth token
		$auth_token = $this->input->cookie('auth_token');
		if (is_string($auth_token))
		{
			// destroy cookie
			$this->auth->destroy_token($auth_token);
			// destroy cookie
			$cookie = array(
				'name'   => 'auth_token',
				'value'  => NULL,
				'expire' => -3600,
				'path'   => '/'
			);
			$this->input->set_cookie($cookie);
		}

		// redirect to login page
		redirect('admin/login');

	}

}
